<template>
	<view class="pad-30">
		<view class="color-646464 mar-bottom-20 font-28">联联、天府通商城、鑫划算（壹划算）、景色优选、千千惠等服务，请在此处输入兑换码进行兑换</view>
		<up-input clearable placeholder="请输入验证码" border="surround" v-model="code"></up-input>
		<view class="mar-top-150">
			<up-button shape="circle" @click="hanldeConvert" type="primary" text="提交"></up-button>

			<view class="mar-top-30 font-28 color-primary flex centerXY" @click="hanldeExchangeLog">
				<view class="mar-right-5">兑换记录</view>
				<up-icon name="arrow-right" color="#0055FE"></up-icon>
			</view>
		</view>
	</view>
</template>

<script setup>
	import { ref } from 'vue';
	import { exchangeApi } from '@/api/index.js';

	// 跳转兑换记录
	const hanldeExchangeLog = () => {
		uni.navigateTo({
			url: '/pages/exchangeLog/exchangeLog'
		})
	}

	// 提交兑换码
	const code = ref('');
	const hanldeConvert = () => {
		if (code.value == '') {
			uni.$u.toast('请输入验证码');
			return
		}

		exchangeApi({
			code: code.value
		}).then(res => {
			if (res.code == 200) {
				uni.$u.toast(res.msg);
			}
		})
	};
</script>

<style>

</style>